#include <iostream>

/**
 * @brief correct the buggy code
 * length - 1 may be buggy in the case length equals 0
*/

float sum_elements(float a[], unsigned length) {
    float result = 0;
    for (int i = 0; i < length; ++i)
        result += a[i];
    return result;
}